      
<link href="{{$LAYOUT_HELPER_URL}}admin/js/jquery-ui/css/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="{{$LAYOUT_HELPER_URL}}admin/js/jquery-ui/js/jquery-ui.js"></script>
<script src="{{$LAYOUT_HELPER_URL}}admin/js/jquery.slug.js"></script>
<!--fancybox-->

<script type="text/javascript" src="{{$LAYOUT_HELPER_URL}}admin/js/fancybox/jquery.fancybox-1.3.4.pack.js"></script>
<link rel="stylesheet" type="text/css" href="{{$LAYOUT_HELPER_URL}}admin/js/fancybox/jquery.fancybox-1.3.4.css" media="screen" />
<!--    <link href="{{$LAYOUT_HELPER_URL}}admin/js/fancybox/fancybox.css" rel="stylesheet" type="text/css" />-->


<script type="text/javascript">
    //<![CDATA[
    jQuery(document).ready(function (){
    //Datepicker
    jQuery( ".date" ).datepicker({
    showAnim        : 'slideDown',
    showButtonPanel : true,
    dateFormat      : '{{$datepickerFormat.js}}'
});
        
jQuery("a[rel=thongke]").fancybox({
'width' : '80%',
'height' : '80%',
'transitionIn'  : 'elastic',
'transitionOut' : 'elastic',
'type': 'iframe'
});
jQuery("a[printBtn").click(function() {
$('#myIframe')[0].print();
});

$('.check-all').click(
function(){
$(this).parent().parent().parent().parent().parent().find("input[type='checkbox']").attr('checked', $(this).is(':checked'));   
}
);
       
});
        
        
function input(id)
{
jQuery('#input' + id).show();
jQuery('#more').hide();
            
}
function output(id)
{
jQuery('#output' + id).show();
jQuery('#more').hide();
}
function showMenu() {
$("#unit").autocomplete( "search" , '' );
}
</script> 

<h2>Manage Book</h2>

<!-- End .shortcut-buttons-set -->

<div class="clear"></div> <!-- End .clear -->



<div class="content-box"><!-- Start Content Box -->

    <div class="content-box-header">

        <div style="float:left;">
            <a name="listofproduct"><h3></h3></a>
        </div>     
        <div style="float:right;padding-right:20px;padding-top:5px;">
            <form class="search" name="search" method="post" action="{{$APP_BASE_URL}}book/admin/manage-product">
                Title <input class="text-input small-input" type="text" name="condition[keyword]" id="keyword" value="{{$condition.keyword}}"/>
                <input class="button" type="submit" value="Search" />
            </form>

        </div>

    </div> <!-- End .content-box-header -->

    <div class="content-box-content">

        <div class="tab-content default-tab" id="tab1"> <!-- This is the target div. id must match the href of this div's tab -->



            <!-- MESSAGE HERE -->
            {{if $allBook|@count <= 0}}
            <div class="notification information png_bg">
                <a href="#" class="close"><img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
                <div>
                    No content with above conditions.
                </div>
            </div>
            {{/if}}

            {{if $bookMessage|@count > 0 && $bookMessage.success == true}}
            <div class="notification success png_bg">
                <a href="#" class="close"><img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
                <div>
                    {{$bookMessage.message}}
                </div>
            </div>
            {{/if}}

            {{if $bookMessage|@count > 0 && $bookMessage.success == false}}
            <div class="notification error png_bg">
                <a href="#" class="close"><img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/cross_grey_small.png" title="Close this notification" alt="close" /></a>
                <div>
                    {{$bookMessage.message}}
                </div>
            </div>
            {{/if}}

            <!-- END MESSAGE -->



            <form method="POST" name="sortForm">
                {{if $allBook|@count > 0}}

                <table>
                    <thead>
                        <tr>
                            <th width="3%"><input class="check-all" type="checkbox" /></th>
                            <th width="18%">Title</th>

                            <th class="center" width="8%">Created Date</th>


                            <th width="6%">Action</th>
                        </tr>

                    </thead>


                    <tbody>

                        {{foreach from=$allBook item=item name=book}}
                        <?php echo 'a';
                        ?>
                        <tr>
                    <table>
                        <tr>
                            <td width="3%"><input type="checkbox" value="{{$item.book_id}}" name="allBook"/></td>

<!--		                                    <td width="7%">{{$item.created_date}}</td>-->
                            <td width="18%">
                                {{foreach from=$item.langs item=item2}}
                                <img style="vertical-align:middle;" src="{{$BASE_URL}}{{$item2.lang_image}}"/>
                                {{$item2.title}}
                                <a href="{{$APP_BASE_URL}}epub/admin/export-epub/id/{{$item2.book_id}}" title="Export epub">
                                <img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/epub-{{$item2.lang_id}}.png"  alt="export Book" /></a>
                                <br>
                                {{/foreach}}
                            </td>


                            <th class="center" width="8%">{{$item.created_date}}</th>


<!--                                            <td width="15%">{{$item.created_date}}</td>-->

                            <td width="6%">
                                {{if $fullPermisison}}
                                <a href="{{$APP_BASE_URL}}book/admin/edit-book/id/{{$item.book_gid}}" title="Edit"><img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/pencil.png"  alt="Edit Book" /></a>
                                <a href="javascript:deleteABook({{$item.book_gid}})" title="Delete"><img src="{{$LAYOUT_HELPER_URL}}admin/images/icons/cross.png"  alt="Delete" /></a>
                                
                                {{else}}
                                --
                                {{/if}}
                            </td>
                        </tr>


                        <tr>
                        </tr>



                        <tr></tr>


                    </table>
                    <!-- END 1 COL -->
                    </tr>
                    {{/foreach}}                     

                    </tbody>
                </table>

            </form>

            <br/>
            <!-- CHOOSE ACTION -->
            {{p name=edit_product module=product}}
            <div class="bulk-actions align-left" style="float: left;padding-top: 14px;">
                <select id="action">
                    <option value=";">Choose an action...</option>
                    {{p name=delete_product module=product}}
                    <option value="deleteProduct();">Delete</option>
                    {{/p}}
                    <option value="enableProduct();">Enable</option>
                    <option value="disableProduct();">Disable</option>
                </select>
                <a class="button" href="javascript:applySelected();">Apply to selected</a>
            </div>
            {{/p}}

            <div class="bulk-actions align-left" style="float: left;padding-top: 10px; padding-left:30px;">
                <form class="search" name="search" method="post" action="{{$APP_BASE_URL}}book/admin/manage-product">
                    Display #
                    <select name="displayNum" onchange="this.parentNode.submit();" style="clear: both;">
                        <option value="5" {{if $displayNum == 5}} selected="selected" {{/if}}>5</option>
                        <option value="10" {{if $displayNum == 10}} selected="selected" {{/if}}>10</option>
                        <option value="20" {{if $displayNum == 20}} selected="selected" {{/if}}>20</option>
                        <option value="50" {{if $displayNum == 50}} selected="selected" {{/if}}>50</option>
                        <option value="100" {{if $displayNum == 100}} selected="selected" {{/if}}>100</option>
                        <option value="1000000000" {{if $displayNum >= 1000000000}} selected="selected" {{/if}}>All</option>
                    </select>
                </form>
            </div>

            <!-- PAGINATION -->
            {{if $countAllPages > 1}}
            <div class="pagination" style="float: right;">
                {{if $first}}
                <a href="?page=1" class="number" title="First Page">&laquo; First</a>
                {{/if}}
                {{if $prevPage}}
                <a href="?page={{$prevPage}}" class="number" title="Previous Page">&laquo;</a>
                {{/if}}

                {{foreach from=$prevPages item=item}}
                <a href="?page={{$item}}" class="number" title="{{$item}}">{{$item}}</a>
                {{/foreach}}

                <a href="#" class="number current" title="{{$currentPage}}">{{$currentPage}}</a>

                {{foreach from=$nextPages item=item}}
                <a href="?page={{$item}}" class="number" title="{{$item}}">{{$item}}</a>
                {{/foreach}}

                {{if $nextPage}}
                <a href="?page={{$nextPage}}" class="number" title="Next Page">&raquo;</a>
                {{/if}}
                {{if $last}}
                <a href="?page={{$countAllPages}}" class="number" title="Last Page">Last &raquo;</a>
                {{/if}}
            </div> <!-- End .pagination -->
            {{/if}}
            {{/if}}    

            <div class="clear"></div>
        </div> <!-- End #tab1 -->


    </div> <!-- End .content-box-content -->

</div> <!-- End .content-box -->


<div class="clear"></div>

<script language="javascript" type="text/javascript">
$(document).ready(function(){
document.getElementById('keyword').select();
document.getElementById('keyword').focus();
});

function applySelected()
{
var task = document.getElementById('action').value;
eval(task);
}
function enableProduct()
{
var all = document.getElementsByName('allProduct');
var tmp = '';
for (var i = 0; i < all.length; i++) {
if (all[i].checked) {
tmp = tmp + '_' + all[i].value;
}
}
if ('' == tmp) {
alert('Please choose an product');
}
window.location.href = '{{$APP_BASE_URL}}book/admin/enable-product/gid/' + tmp;
}

function disableProduct()
{
var all = document.getElementsByName('allProduct');
var tmp = '';
for (var i = 0; i < all.length; i++) {
if (all[i].checked) {
tmp = tmp + '_' + all[i].value;
}
}
if ('' == tmp) {
alert('Please choose an product');
}
window.location.href = '{{$APP_BASE_URL}}book/admin/disable-product/gid/' + tmp;
}

function deleteProduct()
{
var all = document.getElementsByName('allProduct');
var tmp = '';
var count = 0;
for (var i = 0; i < all.length; i++) {
if (all[i].checked) {
tmp = tmp + '_' + all[i].value;
count++;
}
}
if ('' == tmp) {
alert('Please choose an product');
return;
} else {
result = confirm('Are you sure you want to delete ' + count + ' product(s)?');
if (false == result) {
return;
}
}
window.location.href = '{{$APP_BASE_URL}}book/admin/delete-product/gid/' + tmp;
}


function deleteABook(id)
{
result = confirm('Are you sure you want to delete this book?');
if (false == result) {
return;
}
window.location.href = '{{$APP_BASE_URL}}book/admin/delete-book/id/' + id;
}
</script>
